/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
#include "MuRo_AlarmFrame.h"
#include "AlarmBalloon.hpp"

MuRo_AlarmFrame::MuRo_AlarmFrame( wxWindow* parent, MuRo::CAlarmBalloon* alarmBalloon)
:
_AlarmFrame( parent ),
alarmBalloon(alarmBalloon)
{
  std::string header;
  switch(alarmBalloon->data.GetAlarmEvent()->type)
  {
    case MaCI::Alarm::KEventTypeError:
      header="Error:";
      break;
    case MaCI::Alarm::KEventTypeWarning:
      header="Warning:";
      break;
    case MaCI::Alarm::KEventTypeNotification:
      header="Notification:";
      break;
    case MaCI::Alarm::KEventTypeInfo:
      header="Info:";
      break;
    case MaCI::Alarm::KEventTypeDebug:
      header="Debug:";
      break;
  }
  header=header+" ";
  if (alarmBalloon->data.GetHeadingText())
    header.append(alarmBalloon->data.GetHeadingText()->text,
                alarmBalloon->data.GetHeadingText()->length);
  
  staticText_Header->SetLabel(header);
  
  std::string source("Source:");
  if (alarmBalloon->data.GetSourceNameText())
    source.append(alarmBalloon->data.GetSourceNameText()->text,
          alarmBalloon->data.GetSourceNameText()->length);
  staticText_Source->SetLabel(source);
  
  std::string message;
  if (alarmBalloon->data.GetText())
    message.append(alarmBalloon->data.GetText()->text,
                alarmBalloon->data.GetText()->length);
  textCtrl_Message->SetValue(message);
}

void MuRo_AlarmFrame::OnClose( wxCloseEvent& event )
{
	// TODO: Implement OnClose
  alarmBalloon->Expand(false);
}

void MuRo_AlarmFrame::OnDismiss( wxCommandEvent& event )
{
	// TODO: Implement OnDismiss
  alarmBalloon->Destroy();
}

void MuRo_AlarmFrame::OnCloseButton( wxCommandEvent& event )
{
  alarmBalloon->Expand(false);
}
